package view.editorActions;

import singleton.Singleton;
import swtElements.MyText;
import view.views.CSADView;
import controller.UseCaseController;
import controller.data.Comment;
import controller.data.commentDocumentation.CommentDocumentationRequest;
import controller.data.readDocumentation.ReadDocumentationRequest;

public class SaveComments {
	public static void saveComments(MyText textFirstName, MyText textLastName ,MyText textCom){
		Comment comment = new Comment(textCom.getText(), textFirstName
				.getText(), textLastName.getText());
		
		CommentDocumentationRequest request = new CommentDocumentationRequest(
				Singleton.getInstance().getUseCaseController().getId(), comment);
		
		Singleton.getInstance().getUseCaseController().commentDocumentation(
				request);
		
		UseCaseController useTMP = Singleton.getInstance()
				.getUseCaseController();
		CSADView.listOfData = CSADView.listOfData = Singleton.getInstance()
				.getUseCaseController().readDocumentation(
						new ReadDocumentationRequest(Singleton.getInstance()
								.getSelectedTab().getCategoryName(),
								CSADView.searchString));
		Singleton.getInstance().setCommentPrevious(CSADView.listOfData.get(
				 Singleton.getInstance().getListPos()).getComments());
	}
}